package com.cc.service.impl;

import com.cc.entity.Page;
import com.cc.entity.User;
import com.cc.mapper.UserDAO;
import com.cc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: jinjinwen
 * @description: 1
 * @date: 2021-01-14 20:30
// **/

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    @Qualifier("userDAO")
    private UserDAO userDAO;

    @Override
    public void getTList(Page<User> page) {

    }

    @Transactional(rollbackFor=Exception.class)
    @Override
    public User getT(Integer id) {
        return userDAO.getT(id);
    }

    @Override
    @Transactional(rollbackFor=Exception.class)
    public Integer modify(int type,User user){
        if(type==1){//增删改
            Integer integer = userDAO.insertT(user);
            return integer;
        }else if(type==2){
            return userDAO.deleteT(user);
        }else if(type==3){
            return userDAO.updataT(user);
        }
        return null;
    }

    @Override
    public int removeMore(Object... args) {
        return 0;
    }
}
